//
//  MAKCollectionView.h
//  MAKCommon
//
//  Created by zhuwh on 2020/3/27.
//  Copyright © 2020 mark. All rights reserved.
//

#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

@protocol MAKCollectionViewScrollDelegate <NSObject>
@optional
- (void)mak_scrollViewDidScroll:(UIScrollView *)scrollView;
- (void)mak_scrollViewDidZoom:(UIScrollView *)scrollView NS_AVAILABLE_IOS(3_2);

- (void)mak_scrollViewWillBeginDragging:(UIScrollView *)scrollView;
- (void)mak_scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset NS_AVAILABLE_IOS(5_0);
- (void)mak_scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate;

- (void)mak_scrollViewWillBeginDecelerating:(UIScrollView *)scrollView;
- (void)mak_scrollViewDidEndDecelerating:(UIScrollView *)scrollView;

- (void)mak_scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView;
- (nullable UIView *)mak_viewForZoomingInScrollView:(UIScrollView *)scrollView;
- (void)mak_scrollViewWillBeginZooming:(UIScrollView *)scrollView withView:(nullable UIView *)view NS_AVAILABLE_IOS(3_2);
- (void)mak_scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(nullable UIView *)view atScale:(CGFloat)scale;

- (BOOL)mak_scrollViewShouldScrollToTop:(UIScrollView *)scrollView;
- (void)mak_scrollViewDidScrollToTop:(UIScrollView *)scrollView;

- (void)mak_scrollViewDidChangeAdjustedContentInset:(UIScrollView *)scrollView API_AVAILABLE(ios(11.0), tvos(11.0));
@end

@protocol MAKCollectionViewControlDelegate <NSObject>
@optional

- (void)mak_collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath model:(id)model actionId:(NSInteger)actionId;

- (void)mak_inCollectionViewButtonEvent:(UIButton *)button model:(id)model indexPath:(NSIndexPath *)indexPath actionId:(NSInteger)actionId;

- (void)mak_cellHasCollectionView:(UICollectionView *)collectionView atIndexPath:(NSIndexPath *)atIndexPath didSelectItemAtIndexPath:(NSIndexPath *)indexPath model:(id)model cellClass:(NSString *)cellClass;
- (void)mak_cellHasCollectionView:(UICollectionView *)collectionView atIndexPath:(NSIndexPath *)atIndexPath didSelectItemAtIndexPath:(NSIndexPath *)indexPath model:(id)model actionId:(NSInteger)actionId;
@end

@protocol MAKCollectionViewDeletgate <NSObject>

- (void)mak_collectionView:(UICollectionView *)collectionView willDisplayCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath;

- (UICollectionReusableView *)mak_collectionView:(UICollectionView *)collectionView headerViewatIndexPath:(NSIndexPath *)indexPath;
- (UICollectionReusableView *)mak_collectionView:(UICollectionView *)collectionView footerViewatIndexPath:(NSIndexPath *)indexPath;
- (void)mak_collectionView:(UICollectionView *)collectionView didEndDisplayingCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath ;
@end

@interface MAKCollectionView : UICollectionView

@property (nonatomic, strong) id data;
@property (nonatomic, weak) id<MAKCollectionViewControlDelegate> controlDelegate;
@property (nonatomic, weak) id<MAKCollectionViewScrollDelegate> scrollDelegate;
@property (nonatomic, weak) id<MAKCollectionViewDeletgate> makDelegate;


-(void)registerLayout:(UICollectionViewLayout*)layout forKey:(NSString *)key;

-(void)changeLayoutWithKey:(NSString*)key;

@end

NS_ASSUME_NONNULL_END
